# -*- coding: utf-8 -*-
# @Time    : 2021/5/7 22:28
# @Author  : Zhangrenjie
# @Email   : zhangrenjie1998@163.com
# @File    : Fibonacci.py
# @Software: PyCharm
class Fibonacci(object):
    def __init__(self, all_num):
        self.all_num = all_num
        self.current_num = 0
        self.a = 0
        self.b = 1

    def __iter__(self):
        return self

    def __next__(self):
        if self.current_num < self.all_num:
            self.a, self.b = self.b, self.a + self.b
            self.current_num += 1
            return self.a
        else:
            raise StopIteration


fibo = Fibonacci(10)

for num in fibo:
    print(num)

